bitkeeper revision 1.1159.259.1 (420d50b3Mu97o7HHZsGGVPlv3ORCOw)
authoriap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk>
Sat, 12 Feb 2005 00:41:23 +0000 (00:41 +0000)
committeriap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk>
Sat, 12 Feb 2005 00:41:23 +0000 (00:41 +0000)
Some VT-x software perf counters.
Signed-off-by: ian.pratt@cl.cam.ac.uk
xen/arch/x86/vmx.c
xen/include/xen/perfc.h
xen/include/xen/perfc_defn.h

index 01bc3720415af75e8b843528cdcdc48a92cb8de5..0d2ebab22067911693d3c86e028eac515185041e 100644 (file)
@@ -685,6 +685,8 @@ asmlinkage void vmx_vmexit_handler(struct xen_regs regs)
     if ((error = __vmread(VM_EXIT_REASON, &exit_reason)))
         __vmx_bug(&regs);
     
+    perfc_incra(vmexits, exit_reason);
+
     __vmread(IDT_VECTORING_INFO_FIELD, &idtv_info_field);
     if (idtv_info_field & INTR_INFO_VALID_MASK) {
         __vmwrite(VM_ENTRY_INTR_INFO_FIELD, idtv_info_field);
@@ -729,6 +731,8 @@ asmlinkage void vmx_vmexit_handler(struct xen_regs regs)
             __vmx_bug(&regs);
         vector &= 0xff;
 
+        perfc_incra(cause_vector, vector);
+
         switch (vector) {
 #ifdef XEN_DEBUGGER
         case VECTOR_DB:
index ccf8d2ef9ffa66d63f0c2da05282a10d7fbdf06b..cfaef352c8818d2cc906cbe381c30365700cbd7c 100644 (file)
@@ -55,17 +55,25 @@ extern struct perfcounter_t perfcounters;
 
 #define perfc_value(x)    atomic_read(&perfcounters.x[0])
 #define perfc_valuec(x)   atomic_read(&perfcounters.x[smp_processor_id()])
-#define perfc_valuea(x,y) atomic_read(&perfcounters.x[y])
+#define perfc_valuea(x,y) \
+  { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
+    atomic_read(&perfcounters.x[y]); }
 #define perfc_set(x,v)    atomic_set(&perfcounters.x[0], v)
 #define perfc_setc(x,v)   atomic_set(&perfcounters.x[smp_processor_id()], v)
-#define perfc_seta(x,y,v) atomic_set(&perfcounters.x[y], v)
+#define perfc_seta(x,y,v) \
+  { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
+    atomic_set(&perfcounters.x[y], v); }
 #define perfc_incr(x)     atomic_inc(&perfcounters.x[0])
 #define perfc_decr(x)     atomic_dec(&perfcounters.x[0])
 #define perfc_incrc(x)    atomic_inc(&perfcounters.x[smp_processor_id()])
-#define perfc_incra(x,y)  atomic_inc(&perfcounters.x[y])
+#define perfc_incra(x,y)  \
+  { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
+    atomic_inc(&perfcounters.x[y]); }
 #define perfc_add(x,y)    atomic_add((y), &perfcounters.x[0])
 #define perfc_addc(x,y)   atomic_add((y), &perfcounters.x[smp_processor_id()])
-#define perfc_adda(x,y,z) atomic_add((z), &perfcounters.x[y])
+#define perfc_adda(x,y,z) \
+  { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
+    atomic_add((z), &perfcounters.x[y]); }
 
 #else /* PERF_COUNTERS */
 
index f6868d78b988f8292bbcbafa74c04b6b2f9b64c0..ba369f3603df9fff3dd56429324802d32006518d 100644 (file)
@@ -30,3 +30,8 @@ PERFCOUNTER_CPU( shadow_update_va_fail, "shadow_update_va_fail" )
 /* STATUS counters do not reset when 'P' is hit */
 PERFSTATUS( shadow_l2_pages, "current # shadow L2 pages" )
 PERFSTATUS( shadow_l1_pages, "current # shadow L1 pages" )
+
+#define VMX_PERF_EXIT_REASON_SIZE 37
+#define VMX_PERF_VECTOR_SIZE 0x20
+PERFCOUNTER_ARRAY(vmexits, "vmexits", VMX_PERF_EXIT_REASON_SIZE )
+PERFCOUNTER_ARRAY(cause_vector, "cause vector", VMX_PERF_VECTOR_SIZE )